package com.heima.admin.controller;


import com.heima.admin.service.INewsAuthService;
import com.heima.api.IWemediaClient;
import com.heima.model.admin.dtos.NewsAutoDto;
import com.heima.model.base.annotation.Log;
import com.heima.model.base.po.BusinessType;
import com.heima.model.common.dtos.ResponseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author Xanny
 * @Data 2024/8/22 8:36
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/news")
@RequiredArgsConstructor
public class NewsAuthController {

    private final INewsAuthService newsAuthService;

    private final IWemediaClient wemediaClient;

    /**
     * 分页查询文章列表详情
     * @param newsAutoDto
     * @return
     */
    @PostMapping("/list_vo")
    @Log(businessType = BusinessType.QUERY)
    public ResponseResult getList(@RequestBody NewsAutoDto newsAutoDto){
            return newsAuthService.getList(newsAutoDto);
    }

    /**
     * 查看文章详情
     * @param id
     * @return
     */
    @Log(businessType = BusinessType.QUERY)
    @GetMapping("one_vo/{id}")
    public ResponseResult getDetails(@PathVariable Integer id){
        return wemediaClient.getDetailsNews(id);
    }

    @Log(businessType = BusinessType.OTHER)
    @PostMapping("/auth_pass")
    public ResponseResult passNews(@RequestBody NewsAutoDto newsAutoDto){
        return wemediaClient.passNews(newsAutoDto);
    }

    @PostMapping("/auth_fail")
    public ResponseResult failNews(@RequestBody NewsAutoDto newsAutoDto){
        return wemediaClient.failNews(newsAutoDto);
    }
}
